<html>
<head><meta charset="utf-8"><title>Accidental cancellation &amp; statefull protocols · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html">Accidental cancellation &amp; statefull protocols</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="235506219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235506219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zeeshan Ali <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235506219">(Apr 21 2021 at 13:09)</a>:</h4>
<p><span class="user-mention" data-user-id="224872">@rylev</span> If you recall, for <a href="https://github.com/rust-lang/wg-async-foundations/pull/153">https://github.com/rust-lang/wg-async-foundations/pull/153</a>, we deliberately avoided the problem of stateful protocols to keep things simple (and also cause character was Alan IIRC) and since the solution Alan came up with in the end doesn't apply to that problem, I wonder if we need a Barbara story for that?</p>



<a name="235637203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235637203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235637203">(Apr 22 2021 at 08:12)</a>:</h4>
<p>I'm not against it. I'd love to see a short write up describing in a bit of detail the issues that are unique to stateful protocols</p>



<a name="235733519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733519">(Apr 22 2021 at 19:21)</a>:</h4>
<p>I think I would like to have a status quo story that covers <span class="user-mention" data-user-id="296720">@tomaka</span>'s <a href="https://tomaka.medium.com/a-look-back-at-asynchronous-rust-d54d63934a1c">cancellation example</a>, and in particular the interaction with <code>select!</code> here</p>



<a name="235733524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733524">(Apr 22 2021 at 19:21)</a>:</h4>
<p>I'm still pondering it</p>



<a name="235733633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733633">(Apr 22 2021 at 19:22)</a>:</h4>
<p>the key point here seems to be</p>



<a name="235733706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733706">(Apr 22 2021 at 19:23)</a>:</h4>
<p>so, when Rust was first being designed, we intended that cancellation occurred only at coarse boundaries</p>



<a name="235733719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733719">(Apr 22 2021 at 19:23)</a>:</h4>
<p>hence why <code>panic!</code> is meant to kill an entire thread</p>



<a name="235733735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733735">(Apr 22 2021 at 19:23)</a>:</h4>
<p>hence the careful logic around <code>catch_panic!</code></p>



<a name="235733755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733755">(Apr 22 2021 at 19:23)</a>:</h4>
<p>but having <code>select</code> cancel futures .. kind of violates that</p>



<a name="235733796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733796">(Apr 22 2021 at 19:23)</a>:</h4>
<p>the caching problem is different</p>



<a name="235733860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235733860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235733860">(Apr 22 2021 at 19:24)</a>:</h4>
<p>because that involves interaction <em>between</em> tasks</p>



<a name="235735033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235735033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Carl Lerche <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235735033">(Apr 22 2021 at 19:32)</a>:</h4>
<p>(deleted)</p>



<a name="235735202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235735202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235735202">(Apr 22 2021 at 19:33)</a>:</h4>
<p>(there is a way to change topics :)</p>



<a name="235735226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235735226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235735226">(Apr 22 2021 at 19:33)</a>:</h4>
<p>I think editing all the text away causes the message to be deleted</p>



<a name="235735239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235735239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235735239">(Apr 22 2021 at 19:33)</a>:</h4>
<p>(deleted)</p>



<a name="235812471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235812471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235812471">(Apr 23 2021 at 09:31)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I wrote in the issue but I'm not sure what the material difference between <span class="user-mention" data-user-id="296720">@tomaka</span>'s story and <a href="https://github.com/rust-lang/wg-async-foundations/pull/153">https://github.com/rust-lang/wg-async-foundations/pull/153</a> is besides the specific use of the <code>select!</code> macro which seems like a tiny detail and not really the high order bit. Perhaps this would be best as part of the FAQ on <a href="https://github.com/rust-lang/wg-async-foundations/issues/153">wg-async-foundations#153</a> rather than its own story</p>



<a name="235845558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Accidental%20cancellation%20%26%20statefull%20protocols/near/235845558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Accidental.20cancellation.20.26.20statefull.20protocols.html#235845558">(Apr 23 2021 at 14:04)</a>:</h4>
<p>(as we noted in the call today, to me the use of <code>select!</code> is the most important thing)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>